class Parent {
  // 父类构造函数, 用于初始化父类的属性

  constructor(name) {
    this.name = name
  }

  sayName() {
    console.log(this.name)
  }
}
const parent = new Parent('liu')
console.log(parent)
// Parent { name: 'liu' }

class Child extends Parent {
  constructor(name, age) {
    super(name, age)
    this.age = age
  }
}

const child = new Child('li', 18)
console.log(child)
// Child { name: 'li', age: 18 }

class Son extends Parent {
  constructor(name, age) {
    super(name)

    this.age = age
  }

  say() {
    // 调用父类的方法
    super.sayName()
    console.log(this.age)
  }
}

const son = new Son('li', 18)
console.log(son)
// Son { name: 'li', age: 18 }

son.say()
// li
// 18
